package com.xinzhi.controller;


import com.xinzhi.model.Result;
import com.xinzhi.model.User;
import com.xinzhi.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping(value = "/register",method = RequestMethod.POST)
    @ResponseBody
    public Result register(@RequestBody User user){
        return userService.register(user);
    }


    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public Result login(@RequestBody User user){
        return userService.login(user);
    }

    @RequestMapping(value = "/logout")
    @ResponseBody
    public Result logout(@RequestHeader("token") String token){
        return userService.logout(token);
    }

    @RequestMapping(value = "/show")
    @ResponseBody
    public Result show(){
        return Result.ok("成功", "首页");
    }

}
